/**
 * Created by Luanzg on 2020.09.08
 */
import router from '@/router'

export default function checkPermission(value) {
  const roles = router.app.$route.meta.permission // 获取当前栏目路由绑定的权限指令
  if (value && value instanceof Array && value.length > 0) {
    const permissionRoles = value

    const hasPermission = roles.some(role => {
      return permissionRoles.includes(role)
    })

    if (!hasPermission) {
      return false
    }
    return true
  } else {
    return false
    // throw new Error('使用方式： v-permission="[\'admin\',\'editor\']"')
  }
}
